{php include pubTemplate("header")}

{if $TS_USER['userid']}
<script type="text/javascript" src="{SITE_URL}public/js/jquery.upload.v2.js"></script>
<SCRIPT LANGUAGE="JavaScript">

    function getPhotoList(){
        $.get('{SITE_URL}index.php?app=weibo&ac=photo&ts=list',function(rs){
            $("#photo-list").html(rs)
        });
    }

    $(function(){
        $("#upload").upload({
            action: "{SITE_URL}index.php?app=weibo&ac=photo&ts=upload", //上传地址
            fileName: "filedata",    //文件名称。用于后台接收
            params: {token:'{$_SESSION["token"]}'},         //参数
            accept: ".jpg,.png,.jpeg",     //文件类型
            complete: function (rs) {  //上传完成
                //window.location.reload()
                getPhotoList()
            },
            submit: function () {   //提交之前
                //alert("submit");
            }
        });
    })

    function delPhoto(photoid){
        $.post('{SITE_URL}index.php?app=weibo&ac=photo&ts=delete',{'photoid':photoid},function(rs){
            getPhotoList();
        })
    }

    getPhotoList();

</SCRIPT>
{else}
<script>
    $(function(){
        $("#upload").click(function(rs){
            tsNotice('请登录后再上传图片！');
        });
    })
</script>
{/if}

<div class="container">


    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{SITE_URL}">首页</a></li>
            <li class="breadcrumb-item active" aria-current="page">{$TS_APP['appname']}</li>
        </ol>
    </nav>

    <div class="row">


        <div class="col-md-8">


            <div class="card">

                <div class=" border-bottom bg-light p-3">
                    <form id="comm-form" method="post" class="form text-form" action="{SITE_URL}index.php?app=weibo&ac=add" enctype="multipart/form-data">
                        <textarea class="form-control" rows="2" id="title" name="title"></textarea>


                        
                        <div class="d-flex justify-content-between align-items-center mt-2">

                           <div>
                              
                            <a class="fs24" id="upload" title="上传图片"><i class="bi bi-image"></i></a>
                            
                           </div>


                           


                            <div>

                                <!--匿名发布-->
                                {if $TS_SITE['isniming']==1}
                                <span>匿名发布：</span>
                                <input type="radio" name="isniming" value="0" checked> 否
                                <input type="radio" name="isniming" value="1"> 是
                                {/if}

                                <input type="hidden" name="token" value="{$_SESSION['token']}" />
                                <button  class="btn btn-sm btn-info"  type="submit">唠叨一下</button>
                            </div>

                        </div>

                        <div class="weibo-add-photo" id="photo-list">
                            
                        </div>

                    </form>
                </div>

                <div class="card-body">



                    <div class="clear"></div>

                    <div class="weibo_index_list">
                        <ul>
                            {loop $arrWeibo $key $item}
                            <li class="mbtl">
                                <a href="{tsUrl('user','space',array('id'=>$item['user']['userid']))}"><img class="rounded-circle" title="{$item['user']['username']}" alt="{$item['user']['username']}" src="{$item['user']['face']}" width="36" /></a>
                            </li>
                            <li class="mbtr rounded">
                                <div class="author"><a href="{tsUrl('user','space',array('id'=>$item['user']['userid']))}">{$item['user']['username']}</a> <span class="fs12 c9">{$item['addtime']}</span></div>
                                
                                <div class="title">
                                    {$item['title']}
                                </div>

                                {if $item['photo']}
                                <div class="d-flex">
                                    {loop $item['photo'] $pkey $pitem}
                                    <a class="w-25 p-1" href="{tsUrl('weibo','show',array('id'=>$item['weiboid']))}"><img class="w-100" src="{$pitem}">
                                    {/loop}
                                </div>
                                {/if}

                                <p class="tar fs12">

                                    <a href="{tsUrl('weibo','show',array('id'=>$item['weiboid']))}">{if $item['count_comment'] > '0'}({$item['count_comment']}){/if}回复</a>

                                    {if $GLOBALS['TS_USER']['isadmin'] == 1}

                                    <span class="c9">|</span>

                                    <a href="{tsUrl('weibo','delete',array('weiboid'=>$item['weiboid']))}">删除</a>
                                    {/if}

                                </p>
                            </li>
                            <div class="clear"></div>
                            {/loop}
                        </ul>
                    </div>

                    <div class="clear"></div>
                    <div class="page">{$pageUrl}</div>
                    <div>

                    </div>

                </div>
            </div>


        </div>


        <div class="col-md-4">

            <div class="card">
                <div class="card-header">热门唠叨</div>
                <div class="card-body">

                    <div class="weilist">
                        <ul>
                            {loop $arrHotWeibo $key $item}
                            <li>
                                <div class="portrait">
                                    <a href="{tsUrl('user','space',array('id'=>$item['user']['userid']))}"><img class="rounded-circle" title="{$item['user']['username']}" alt="{$item['user']['username']}" src="{$item['user']['face']}"></a>
                                </div>
                                <div class="body">
                                    <div>
                                        <span class="user"><a href="{tsUrl('user','space',array('id'=>$item['user']['userid']))}">{$item['user']['username']}</a>：</span><span class="log">{$item['title']}</span>
                                    </div>

                                    {if $item['photo']}
                                    <div class="d-flex">
                                        {loop $item['photo'] $pkey $pitem}
                                        <a class="w-25 p-1" href="{tsUrl('weibo','show',array('id'=>$item['weiboid']))}"><img class="w-100" src="{$pitem}">
                                        {/loop}
                                    </div>
                                    {/if}

                                    <div class="time">{php echo getTime(strtotime($item['addtime']),time())} (<a href="{tsUrl('weibo','show',array('id'=>$item['weiboid']))}">{$item['count_comment']}评</a>)
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </li>
                            {/loop}
                        </ul>
                    </div>

                </div>
            </div>



            <!--广告位-->
            {php doAction('gobad','300')}


        </div>


    </div>
</div>
{php include pubTemplate("footer")}